#ifndef DOCTOR_CHATLISTWIDGET_H
#define DOCTOR_CHATLISTWIDGET_H

#include <QWidget>
#include <QTimer>
#include "../../../Common/models.h"
#include "../../../Common/protocol.h"

namespace Ui {
class DoctorChatListWidget;
}

class DoctorChatListWidget : public QWidget
{
    Q_OBJECT

public:
    explicit DoctorChatListWidget(int doctorId, QWidget *parent = nullptr);
    ~DoctorChatListWidget();

private slots:
    void onMessageReceived(MessageType type, const QJsonObject& data);
    void onChatButtonClicked();
    void refreshPatientList();

private:
    Ui::DoctorChatListWidget *ui;
    int m_doctorId;
    QTimer* m_refreshTimer;          // 定时刷新未读消息数
    
    void loadPatients();
    void updatePatientTable(const QJsonArray& patientsArray);
    void openChatWindow(int patientId, const QString& patientName);
};

#endif // DOCTOR_CHATLISTWIDGET_H

